import smtplib
from email.mime.text import MIMEText


def send_email(content, email, myprice):
    mail_host = 'smtp.163.com'
    mail_user = 'vjmbsd'
    mail_pass = 'HVYZEVNOSEOYSADS'
    sender = 'vjmbsd@163.com'
    receivers = [email,'vjmbsd@163.com'] if email else ['2391860056@qq.com','vjmbsd@163.com']

    message = MIMEText(content, 'plain', 'utf-8')
    message['Subject'] = f'{myprice}'
    message['From'] = sender
    message['To'] = ';'.join(receivers)

    try:
        smtp = smtplib.SMTP_SSL("smtp.163.com", 465)
        # 登录到服务
        smtp.login(mail_user, mail_pass)
        # 发送
        smtp.sendmail(sender, receivers, message.as_string())
        # 退出
        smtp.quit()
        print('Email sent successfully')
    except smtplib.SMTPException as e:
        print(f'Error sending email: {e}')
        mail_user = 'nshyx2292601665'
        mail_pass = 'HNtAz6quUg4ncav3'
        sender = 'nshyx2292601665@163.com'
        smtp = smtplib.SMTP_SSL("smtp.163.com", 465)
        # 登录到服务
        smtp.login(mail_user, mail_pass)
        # 发送
        smtp.sendmail(sender, receivers, message.as_string())
        # 退出
        smtp.quit()
        print('Email1 sent successfully')
send_email('123','2391860056@qq.com',100)